#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>

using namespace std;

const int ARRAY_SIZE = 5;

int main()
{
    // 存储输入的数字
    int numbers[ARRAY_SIZE] = { 0 };
    int matchCount = 0;
    
    // 读取输入
    cout << "请输入" << ARRAY_SIZE << "个四位数：" << endl;
    for (int i = 0; i < ARRAY_SIZE; i++)
    {
        cin >> numbers[i];
        
        // 验证输入是否为四位数
        if (numbers[i] < 1000 || numbers[i] > 9999)
        {
            cout << "错误：请输入四位数！" << endl;
            i--; // 重新输入当前数字
            continue;
        }
    }

    // 检查每个数字是否满足条件：
    // 千位数字等于十位数字，且个位数字等于百位数字加1
    for (int i = 0; i < ARRAY_SIZE; i++)
    {
        const int thousands = numbers[i] / 1000;
        const int hundreds = (numbers[i] / 100) % 10;
        const int tens = (numbers[i] / 10) % 10;
        const int units = numbers[i] % 10;

        if (thousands == tens && units == hundreds + 1)
        {
            matchCount++;
        }
    }
    
    // 输出结果
    cout << "满足条件的数字个数：" << matchCount << endl;

    return 0;
}